#include <iostream>
#include <gtest/gtest.h>
#include<unordered_map>
class MyEnvironment : public testing::Environment
{
public:
    // Override this to define how to set up the environment.
    virtual void SetUp() {
        std::cout<<"单元测试前的初始化"<<std::endl;
    }

    // Override this to define how to tear down the environment.
    virtual void TearDown() {
        std::cout<<"单元测试结束后的清理"<<std::endl;
    }
};
TEST(MyEnvironment,test1)
{
    std::cout<<"单元测试test1"<<std::endl;
}
TEST(MyEnvironment,test2)
{
    std::cout<<"单元测试test2"<<std::endl;
}

std::unordered_map<std::string,std::string> mymap;
class MyMapTest : public testing::Environment
{
public:
    // Override this to define how to set up the environment.
    virtual void SetUp() {
        std::cout<<"单元测试前的初始化"<<std::endl;
        mymap.insert({"hello","你好"});
        mymap.insert({"bye","再见"});

    }

    // Override this to define how to tear down the environment.
    virtual void TearDown() {
        std::cout<<"单元测试结束后的清理"<<std::endl;
        mymap.clear();
    }
};

TEST(MyMapTest,test1)
{
    ASSERT_EQ(mymap.size(),2);
    mymap.erase("hello");
}
TEST(MyMapTest,test2)
{
    ASSERT_EQ(mymap.size(),2);
}
int main(int argc,char*argv[])
{
    testing::InitGoogleTest(&argc,argv);
    testing::AddGlobalTestEnvironment(new MyEnvironment);
    testing::AddGlobalTestEnvironment(new MyMapTest);

    int ret = RUN_ALL_TESTS();
    (void)ret;
    return 0;
}